package com.example.wac.controller;


import com.example.wac.service.GoodsService;
import com.example.wac.vo.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author wac
 * @since 2022-01-12
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    GoodsService goodsService;

    /**
     * 分布式锁下抢占物品
     *
     * @return
     */
    @PostMapping("/distributed_lock")
    public ApiResult distributedLock(@RequestParam("goodsId") Integer goodsId){
        return goodsService.distributedLock(goodsId);
    }

    /**
     * 单机锁下抢占物品
     *
     * @return
     */
    @PostMapping("/single_lock")
    public ApiResult singleLock(@RequestParam("goodsId") Integer goodsId){
        return goodsService.singleLock(goodsId);
    }
}

